package day8;

public
class TestRunnable implements Runnable{
    @Override
    public
    void run() {
        String name=Thread.currentThread().getName();// 获取当前线程的名字
        for (int i=0;i<10;i++){
            System.out.println(name+"："+i);
        }
    }

    public static
    void main(String[] args) {
        //不是线程对象（和Thread无关） 只是线程的实现方式
        TestRunnable t=new TestRunnable();
        Thread t1=new Thread(t,"线程1");
        Thread t2=new Thread(t,"线程2");
        Thread t3= new Thread(()->{
            String name=Thread.currentThread().getName();// 获取当前线程的名字
            for (int i=0;i<10;i++) {
                System.out.println(name + "：" + i);
            }
        },"线程3");
        t1.start();
        t2.start();
        t3.start();
    }
}
